package com.astersoft.lib.util.singleton;

import com.astersoft.lib.util.singleton.factory.ASSingletonFactory;
import com.astersoft.lib.util.singleton.factory.ItemHolder;

public class Test extends ASSingleton<Test> {
	
	public String sayHello() {
		return "Ciao";
	}
	
	public static void main(String[] args) {
		Test t = Test.getInstance(Test.class);
		Test t2 = Test.getInstance(Test.class);
		
		if (t == t2) {
			System.out.println("Sono uguali");
		} else {
			System.out.println("Sono diversi");
		}
		
		ItemHolder<Test> r = ASSingletonFactory.getFactory().getInstance(Test.class);
		ItemHolder<Test> r2 = ASSingletonFactory.getFactory().getInstance(Test.class);
		
		if (r == r2) {
			System.out.println("Sono uguali");
		} else {
			System.out.println("Sono diversi");
		}
		
		System.out.println(r.getItem().sayHello());
	}
}
